package com.xnyzc.lhy.mis.service.impl.cms.journal;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.mis.entity.cms.journal.OaSysJournal;
import com.xnyzc.lhy.mis.mapper.cms.journal.OaSysJournalMapper;
import com.xnyzc.lhy.mis.service.cms.journal.IOaSysJournalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 系统日志表 服务实现类
 * </p>
 *
 * @author zhaolijie
 * @since 2019-09-25
 */
@Service
public class OaSysJournalServiceImpl implements IOaSysJournalService {

    @Autowired
    private OaSysJournalMapper oaSysJournalMapper;


    /**
     * 分页获取日志信息
     * @param ip：IP
     * @param current：需要查询的页码
     * @return
     */
    @Override
    public Rv getJournalList(String ip, Integer current) {
        IPage iPage = new Page();
        iPage.setSize(20);
        iPage.setCurrent(current);
        QueryWrapper<OaSysJournal> queryWrapper = new QueryWrapper<OaSysJournal>();
        queryWrapper.orderByDesc(OaSysJournal.CREATE_TIME);
        if (ip != null && ip != "" && ip.length() != 0) {
            queryWrapper.like(OaSysJournal.OPERATOR_IP, ip);
        }
        iPage.setRecords(oaSysJournalMapper.selectPage(iPage, queryWrapper).getRecords());
        return Rv.wrap(EErrorCode.success, iPage);
    }
}
